public class Test2 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
           while(!Thread.currentThread().isInterrupted()){
               System.out.println("线程正在工作");
               try {
                   Thread.sleep(600);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
        });
        thread.start();
        Thread.sleep(500);
        thread.interrupt();
    }
}
